package com.zzy.controller;

import com.zzy.domain.Login;
import com.zzy.domain.Result;
import com.zzy.domain.vo.LoginInfoVo;
import com.zzy.service.LoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class LoginController {
    private final LoginService loginService;

    @PostMapping("/login")
    public Result login(@RequestBody Login login){
        LoginInfoVo vo = loginService.login(login);
        if(vo != null){
            return Result.success(vo);
        }
        return Result.error("登录名或者用户名称错误");
    }
}
